package assignment1;


public class Converter {
	
	public static char ConvertCharToNumberPhone(char c){
		
		char n='0';
		switch(c)
		{
		case 'a':
		case 'b':
		case 'c':
		case 'A':
		case 'B':
		case 'C':
			n='2';
			break;
		case 'd':
		case 'e':
		case 'f':
		case 'D':
		case 'E':
		case 'F':
			n='3';
			break;
		case 'g':
		case 'h':
		case 'i':
		case 'G':
		case 'H':
		case 'I':
			n='4';
			break;
		case 'j':
		case 'k':
		case 'l':
		case 'J':
		case 'K':
		case 'L':
			n='5';
			break;
		case 'm':
		case 'n':
		case 'o':
		case 'M':
		case 'N':
		case 'O':
			n='6';
			break;
		case 'p':
		case 'q':
		case 'r':
		case 's':
		case 'P':
		case 'Q':
		case 'R':
		case 'S':
			n='7';
			break;
		case 't':
		case 'u':
		case 'v':
		case 'T':
		case 'U':
		case 'V':
			n='8';
			break;
		case 'w':
		case 'x':
		case 'y':
		case 'z':
		case 'W':
		case 'X':
		case 'Y':
		case 'Z':
			n='9';
			break;
		default:
				n='0';
		}
		return n;
	}
	
	public static String ConvertWordToKey(String word){
		
		String result="";
		
		for(char c : word.toCharArray())
		{
			char n= ConvertCharToNumberPhone(c);
			result= result+n;
		}
		return result;
	}
	
}
